package com.shushan.mixedexam.bean;

import com.android.net.bean.NetBaseBean;
import com.shushan.base.Constants;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: MutiExercisePaperBean
 * @Desciption: //多种练习试卷数据bean
 * @author: zhangshihao
 * @date: 2018-07-31
 */
public class MutiExercisePaperBean extends NetBaseBean {

    private List<MutiExerciseBean> chineseExerciseBeans = new ArrayList<>();
    private List<MutiExerciseBean> mathExerciseBeans = new ArrayList<>();
    private List<MutiExerciseBean> englishExerciseBeans = new ArrayList<>();

    private List<MutiExerciseBean> paperBeans = new ArrayList<>();

    public NewTypePaperInfoBean paperInfoBean;

    @Override
    public void initByJson(JSONObject jsonObject) throws JSONException {
        if(jsonObject == null){
            return;
        }
        JSONArray chineseArr = jsonObject.optJSONArray(Constants.SUBJECT_CHINESE_ID+"");
        if(chineseArr != null && chineseArr.length() > 0){
            for(int i=0;i<chineseArr.length();i++){
                JSONObject chineseObj = chineseArr.optJSONObject(i);
                MutiExerciseBean exerciseBean = new MutiExerciseBean();
                exerciseBean.initByJson(chineseObj);
                chineseExerciseBeans.add(exerciseBean);
            }
        }

        JSONArray mathArr = jsonObject.optJSONArray(Constants.SUBJECT_MACH_ID+"");
        if(mathArr != null && mathArr.length() > 0){
            for(int i=0;i<mathArr.length();i++){
                JSONObject mathObj = mathArr.optJSONObject(i);
                MutiExerciseBean exerciseBean = new MutiExerciseBean();
                exerciseBean.initByJson(mathObj);
                mathExerciseBeans.add(exerciseBean);
            }
        }

        JSONArray englishArr = jsonObject.optJSONArray(Constants.SUBJECT_ENGLISH_ID+"");
        if(englishArr != null && englishArr.length() > 0){
            for(int i=0;i<englishArr.length();i++){
                JSONObject englishObj = englishArr.optJSONObject(i);
                MutiExerciseBean exerciseBean = new MutiExerciseBean();
                exerciseBean.initByJson(englishObj);
                englishExerciseBeans.add(exerciseBean);
            }
        }

        JSONObject paperInfoObj = jsonObject.optJSONObject("paper_info");
        if(paperInfoObj != null){
            paperInfoBean = new NewTypePaperInfoBean();
            paperInfoBean.initByJson(paperInfoObj);
        }

        JSONArray paperArr = jsonObject.optJSONArray("paper");
        if(paperArr != null && paperArr.length() > 0){
            for(int i=0;i<paperArr.length();i++){
                JSONObject obj = paperArr.optJSONObject(i);
                MutiExerciseBean exerciseBean = new MutiExerciseBean();
                exerciseBean.initByJson(obj);
                paperBeans.add(exerciseBean);
            }
        }

    }

    public List<MutiExerciseBean> getChineseExerciseBeans() {
        return chineseExerciseBeans;
    }

    public List<MutiExerciseBean> getMathExerciseBeans() {
        return mathExerciseBeans;
    }

    public List<MutiExerciseBean> getEnglishExerciseBeans() {
        return englishExerciseBeans;
    }

    public void setChineseExerciseBeans(List<MutiExerciseBean> chineseExerciseBeans) {
        this.chineseExerciseBeans = chineseExerciseBeans;
    }

    public void setMathExerciseBeans(List<MutiExerciseBean> mathExerciseBeans) {
        this.mathExerciseBeans = mathExerciseBeans;
    }

    public void setEnglishExerciseBeans(List<MutiExerciseBean> englishExerciseBeans) {
        this.englishExerciseBeans = englishExerciseBeans;
    }

    public List<MutiExerciseBean> getPaperBeans() {
        return paperBeans;
    }

    public void setPaperBeans(List<MutiExerciseBean> paperBeans) {
        this.paperBeans = paperBeans;
    }

}
